﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using SolutionModel;
using SFast;
using SolutionDAL;
using System.IO;
using System.Net;

namespace TestConsole
{
    public class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine(CommonClassType.News.GetHashCode());
            //Console.WriteLine(CommonClassType.News._GetRemark());
            //Console.WriteLine(((CommonClassType)0)._GetRemark());
            //Console.WriteLine(((CommonClassType)Enum.Parse(typeof(CommonClassType), "1"))._GetRemark());
            //CommonClassType newc = "新闻分类asdasd"._RemarkToEnum<CommonClassType>();
            //bool a = CommonClassType.News == newc;
            //CommonClassDAL ccd = new CommonClassDAL();
            ////ccd.Insert(null);
            ////ccd.Delete();

            //procedure pro = new procedure();

            //String insert = pro.createInsert();
            //String update = pro.CreateUpdate();
            //String delete = pro.createDelete();


            //GoogleSTT();

            Console.Write("aaa");
            Console.Write("bbb");
            Console.WriteLine("aaa");
            Console.WriteLine("bbb");

        }

        private static string GoogleSTT()
        {
            string result = string.Empty;
            try
            {
                string inFile = "E:\\个人文件\\open.wav";
                FileStream fs = new FileStream(inFile, FileMode.Open);
                byte[] voice = new byte[fs.Length];
                fs.Read(voice, 0, voice.Length);
                fs.Close();
                HttpWebRequest request = null;
                string url = "http://www.google.com/speech-api/v1/recognize?xjerr=1&client=chromium&lang=zh-CN&maxresults=1";
                Uri uri = new Uri(url);
                request = (HttpWebRequest)WebRequest.Create(uri);
                request.Method = "POST";
                request.ContentType = "audio/x-flac; rate=44100";
                request.ContentLength = voice.Length;
                using (Stream writeStream = request.GetRequestStream())
                {
                    writeStream.Write(voice, 0, voice.Length);
                }

                using (HttpWebResponse response = (HttpWebResponse)request.GetResponse())
                {
                    using (Stream responseStream = response.GetResponseStream())
                    {
                        using (StreamReader readStream = new StreamReader(responseStream, Encoding.UTF8))
                        {
                            result = readStream.ReadToEnd();
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.StackTrace);
            }
            return result;
        }
    }
}
